/**
 * 统一问题兼容处理
 */
import { Text, TextInput, Platform } from 'react-native'

// 禁止字体缩放
Text.defaultProps = { ...Text.defaultProps, allowFontScaling: false }
TextInput.defaultProps = { ...TextInput.defaultProps, allowFontScaling: false }

// 解决部分安卓机型文本最后一个字符被裁切的问题
// https://segmentfault.com/a/1190000039002723
const TextRender = Text.render
const customStyle = Platform.OS === 'android' ? { fontFamily: '' } : {}
Text.render = function render(props, ...rest) {
  const mergedProps = { ...props, style: [customStyle, props.style] }
  return TextRender.apply(this, [mergedProps, ...rest])
}
